﻿<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna"   
  xmlns:system="clr-namespace:System;assembly=mscorlib" 
  xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary">

    <ResourceDictionary.MergedDictionaries>
        <!--<ResourceDictionary Source="DefaultThemeBrushes.xaml" />-->
    </ResourceDictionary.MergedDictionaries>

    <!--
  *****************************************************************************
  BRUSHES
  *****************************************************************************
  -->

       
    <!--
  *****************************************************************************
  METRICS
  *****************************************************************************
  -->

    <system:Int32 x:Key="RibbonToolTipInitialShowDelay">900</system:Int32>
    <system:Int32 x:Key="RibbonToolTipShowDuration">20000</system:Int32>
    <system:Double x:Key="RibbonFontSizeMedium">11</system:Double>
    <system:Double x:Key="RibbonFontSizeSmall">10</system:Double>

    <!--
  *****************************************************************************
  ICONS AND IMAGES
  *****************************************************************************
  -->

    <Geometry x:Key="DownArrowGeometry">M 0 0 L 2.5 3 L 5 0 Z</Geometry>

    <!--
  *****************************************************************************
  SHARED OBJECTS
  *****************************************************************************
  -->

    <!--
  *****************************************************************************
  STYLES AND TEMPLATES
  *****************************************************************************
  -->



    <!-- Ribbon -->

    <Style x:Key="GlowingText" TargetType="{x:Type Label}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Label}">
                    <Grid Margin="-17,3,17,-3">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="18" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="18" />
                        </Grid.ColumnDefinitions>
                        <Rectangle Name="leftGlow" Grid.Column="0" Height="24" RenderOptions.EdgeMode="Aliased"
                                   Fill="{DynamicResource GlowingTextLeftGlowBackgroundBrush}">                            
                        </Rectangle>
                        <Rectangle Name="centerGlow" Grid.Column="1" Height="24" 
                                   RenderOptions.EdgeMode="Aliased"
                                   Fill="{DynamicResource GlowingTextCenterGlowBackgroundBrush}">                          
                        </Rectangle>
                        <Rectangle Name="rightGlow" Grid.Column="2" Height="24" 
                                   RenderOptions.EdgeMode="Aliased"
                                   Fill="{DynamicResource GlowingTextRightGlowBackgroundBrush}">
                             
                        </Rectangle>
                        <TextBlock Text="{TemplateBinding Content}"
              TextTrimming="CharacterEllipsis"
              Margin="0,-3,0,3"
              VerticalAlignment="Bottom"
              Grid.Column="1" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=r:Ribbon}, Path=IsHostedInRibbonWindow}" Value="False">
                            <Setter TargetName="leftGlow" Property="Visibility" Value="Hidden" />
                            <Setter TargetName="centerGlow" Property="Visibility" Value="Hidden" />
                            <Setter TargetName="rightGlow" Property="Visibility" Value="Hidden" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=WindowState}" Value="Maximized">
                            <Setter TargetName="leftGlow" Property="Visibility" Value="Hidden" />
                            <Setter TargetName="centerGlow" Property="Visibility" Value="Hidden" />
                            <Setter TargetName="rightGlow" Property="Visibility" Value="Hidden" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Type r:Ribbon}" TargetType="{x:Type r:Ribbon}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type r:Ribbon}">
                    <ControlTemplate.Resources>
                        <Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
                            <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                            <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment,RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                            <Setter Property="Padding" Value="0,0,3,0"/>
                            <Setter Property="Background" Value="Transparent"/>
                            <Setter Property="BorderThickness" Value="1"/>
							<!-- JAIMER HACK; needs a designers eye-->
							<Setter Property="Foreground" Value="Black" /> 

							<Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type MenuItem}">
                                        <Grid>
                                            <Border Name="Sidebar"
                        Background="{DynamicResource {x:Static r:RibbonSkinResources.MenuItemSidebarBackgroundBrushKey}}"
                        BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.MenuItemSidebarBorderBrushKey}}"
                        BorderThickness="0,0,1,0"
                        HorizontalAlignment="Left"
                        Width="24" 
                        SnapsToDevicePixels="True" />
                                            <Border Name="OuterBorder"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="1"
                        MinHeight="22"
                        SnapsToDevicePixels="true" />
                                            <Border Name="InnerBorder"
                        BorderThickness="1"
                        Margin="1"
                        Padding="{TemplateBinding Padding}" />
                                            <ContentPresenter x:Name="Icon"
                        Margin="5,0,3,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center"
                        ContentSource="Icon"
                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                        
                        />
                                            <Border Name="CheckmarkBackground"
                        BorderThickness="1"
                        Margin="1"
                        Width="20"
                        Height="20"
                        CornerRadius="2"
                        HorizontalAlignment="Left"
                        Background="{DynamicResource {x:Static r:RibbonSkinResources.MenuItemCheckmarkBackgroundBrushKey}}"
                        BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.MenuItemCheckmarkBorderBrushKey}}"
                        Visibility="Collapsed"
                        SnapsToDevicePixels="True" />
                                            <Path Name="Checkmark"
                        Margin="7,0,0,0"
                        Visibility="Collapsed"
                        VerticalAlignment="Center"
                        Fill="{DynamicResource {x:Static r:RibbonSkinResources.RibbonFontColorBrushKey}}"
                        Data="{StaticResource MenuItemCheckmark}"/>
                                            <!-- Header Content -->
                                            <ContentPresenter Margin="29,0,5,0"
                        ContentSource="Header"
                        RecognizesAccessKey="True"
                        VerticalAlignment="Center"
                        TextBlock.Foreground="Black"
                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                            <!-- Submenu Popup -->
                                            <Popup x:Name="PART_Popup"
                         HorizontalOffset="1"
                         VerticalOffset="-1"
                         AllowsTransparency="true"
                         Placement="Bottom"
                         IsOpen="{Binding Path=IsSubmenuOpen,RelativeSource={RelativeSource TemplatedParent}}"
                         Focusable="false"
                         PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
                                                <theme:SystemDropShadowChrome Name="Shdw" Color="Transparent" SnapsToDevicePixels="true" CornerRadius="2">
                                                    <ContentControl Name="SubMenuBorder"
                            Template="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=SubmenuContent}}"
                            IsTabStop="false">
                                                        <ScrollViewer CanContentScroll="true"
                              Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
                                                            <ItemsPresenter Margin="2"
                                KeyboardNavigation.TabNavigation="Cycle"
                                KeyboardNavigation.DirectionalNavigation="Cycle"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                Grid.IsSharedSizeScope="true"/>
                                                        </ScrollViewer>
                                                    </ContentControl>
                                                </theme:SystemDropShadowChrome>
                                            </Popup>
                                        </Grid>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                                                <Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None"/>
                                            </Trigger>
                                            <Trigger Property="Icon" Value="{x:Null}">
                                                <Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
                                            </Trigger>
                                            <Trigger SourceName="PART_Popup" Property="Popup.HasDropShadow" Value="true">
                                                <Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5"/>
                                                <Setter TargetName="Shdw" Property="Color" Value="#71000000"/>
                                            </Trigger>
                                            <Trigger Property="IsHighlighted" Value="true">
                                                <Setter Property="Background" Value="{DynamicResource {x:Static r:RibbonSkinResources.RibbonButtonIsMouseOverSmallBackgroundBrushKey}}" />
                                                <Setter Property="BorderBrush" Value="{DynamicResource {x:Static r:RibbonSkinResources.RibbonButtonIsMouseOverBorderBrushKey}}"/>
                                                <Setter Property="BorderBrush" Value="White" TargetName="InnerBorder"/>
                                                <Setter TargetName="Sidebar" Property="Visibility" Value="Hidden" />
                                            </Trigger>
                                            <Trigger Property="IsChecked" Value="True">
                                                <Setter TargetName="Checkmark" Property="Visibility" Value="Visible" />
                                                <Setter TargetName="CheckmarkBackground" Property="Visibility" Value="Visible" />
                                            </Trigger>
                                            <Trigger Property="IsEnabled" Value="false">
                                                <Setter Property="Foreground" Value="#FF9A9A9A"/>
                                            </Trigger>
                                        </ControlTemplate.Triggers>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ControlTemplate.Resources>

                    <Grid ClipToBounds="True" SnapsToDevicePixels="True" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <!-- Ribbon Background -->
                        <Border Grid.Row="1" Grid.ColumnSpan="2" Grid.RowSpan="3" Background="{DynamicResource {x:Static r:RibbonSkinResources.RibbonBackgroundBrushKey}}" />
                        <Border 
              Name="titleBarBackground"
              Grid.ColumnSpan="2"
              Background="{DynamicResource {x:Static r:RibbonSkinResources.GroupHostBackgroundBrushKey}}" />

                        <!-- Popup hosting the groups when IsMinimized=true -->
                        <Border Grid.ColumnSpan="2"  Grid.Row="1" Margin="3,0,3,0">
                            <Popup x:Name="PART_SELECTEDGROUPSPOPUP" AllowsTransparency="True" PopupAnimation="Fade" >
                                <theme:SystemDropShadowChrome Name="Shdw">
                                    <Border Background="{TemplateBinding Background}">
                                        <ContentControl x:Name="popupGroupHost" />
                                    </Border>
                                </theme:SystemDropShadowChrome>
                            </Popup>
                        </Border>

                        <!-- Panel hosting the groups -->
                        <ContentControl x:Name="mainGroupHost" Grid.ColumnSpan="2" Grid.Row="2" Margin="0" Focusable="False">
                            <Border 
                x:Name="groupsBorder"
                Background="{DynamicResource {x:Static r:RibbonSkinResources.GroupHostBackgroundBrushKey}}" 
                BorderThickness="0,1,0,1"
                Height="110"
                SnapsToDevicePixels="True" BorderBrush="{DynamicResource RibbonGroupHostBackroundBorderBrush}">
                                 <r:HorizontalScrollViewer x:Name="PART_SELECTEDGROUPSHOST" Margin="1" />
                            </Border>
                        </ContentControl>

                        <!-- Separator between title and tabs -->
                        <Border Grid.ColumnSpan="2" Grid.Row="1" Background="White" Height="1" VerticalAlignment="Top"/>

                        <!-- Panel hosting the tab headers -->
                        <r:HorizontalScrollViewer x:Name="tabsScrollViewer" Grid.Row="1" Grid.Column="1" Height="30" Margin="3,1,3,-1">
                            <r:RibbonTabPanel x:Name="PART_TABSHOST" />
                        </r:HorizontalScrollViewer>

                        <!-- TitleBar -->
                        <DockPanel Grid.Column="1" Height="23">
                            <!-- This makes sure that the title and QAT does not overlap the close minimize and restore buttons. -->
                            <ContentControl 
                x:Name="windowButtonPlaceHolder" 
                Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=CaptionButtonsReservedWidth}"  
                IsHitTestVisible="False" 
                DockPanel.Dock="Right" 
                Focusable="False"/>
                            <r:RibbonTitlePanel x:Name="PART_TITLEHOST">
                                <r:RibbonTitlePanel.QuickAccessToolBarPlaceholder>
                                    <Grid IsHitTestVisible="True">
                                        <ContentPresenter x:Name="QatTopHost" Margin="-5,0,0,0" Content="{TemplateBinding QuickAccessToolBar}"/>
                                    </Grid>
                                </r:RibbonTitlePanel.QuickAccessToolBarPlaceholder>
                                <r:RibbonTitlePanel.TitlePlaceholder>
                                    <Label Name="titleText"
                     Margin="3,-5,3,5"
                     Foreground="{StaticResource {x:Static SystemColors.ActiveCaptionTextBrushKey}}"
                     Content="{TemplateBinding Title}"
                     FontSize="13"
                     HorizontalAlignment="Center"
                     VerticalAlignment="Center"
                     Style="{StaticResource GlowingText}"
                     IsHitTestVisible="False" />
                                </r:RibbonTitlePanel.TitlePlaceholder>
                            </r:RibbonTitlePanel>

                        </DockPanel>

                        <!-- Application Menu -->
                        <ContentPresenter x:Name="applicationMenu" Grid.RowSpan="2" Content="{TemplateBinding ApplicationMenu}" />

                        <!-- QuickAccessToolbar bottom placeholder -->
                        <ContentPresenter x:Name="QatBottomHost" Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Left" VerticalAlignment="Center" IsHitTestVisible="True"/>

                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsCollapsed" Value="true">
                            <Setter Property="Visibility"  Value="Collapsed" TargetName="applicationMenu"/>
                            <Setter Property="Visibility"  Value="Collapsed" TargetName="QatBottomHost"/>
                            <Setter Property="Visibility"  Value="Collapsed" TargetName="QatTopHost"/>
                            <Setter Property="Visibility"  Value="Collapsed" TargetName="tabsScrollViewer"/>
                            <Setter Property="Visibility"  Value="Collapsed" TargetName="mainGroupHost"/>
                        </Trigger>
                        <Trigger Property="ShowQuickAccessToolbarOnTop" Value="false">
                            <Setter Property="Content"  Value="{x:Null}" TargetName="QatTopHost"/>
                            <Setter Property="Content"  Value="{Binding Path=QuickAccessToolBar,RelativeSource={RelativeSource TemplatedParent}}" TargetName="QatBottomHost"/>
                        </Trigger>
                        <Trigger Property="IsMinimized" Value="True">
                            <Setter Property="Content"  Value="{x:Null}" TargetName="mainGroupHost"/>
                            <Setter Property="Content"  Value="{Binding ElementName=groupsBorder}" TargetName="popupGroupHost"/>
                        </Trigger>
                        <Trigger Property="IsHostedInRibbonWindow" Value="True">
                            <Setter TargetName="titleBarBackground" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMinimized" Value="true" />
                                <Condition Property="IsOpen" Value="true" />
                            </MultiTrigger.Conditions>
                            <Setter Property="IsOpen"  Value="true" TargetName="PART_SELECTEDGROUPSPOPUP"/>
                        </MultiTrigger>
                        <Trigger SourceName="PART_SELECTEDGROUPSPOPUP" Property="Popup.HasDropShadow" Value="true">
                            <Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5"/>
                            <Setter TargetName="Shdw" Property="Color" Value="#71000000"/>
                        </Trigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=IsActive}" Value="False">
                            <Setter TargetName="titleText" Property="Foreground" Value="{x:Static SystemColors.InactiveCaptionTextBrush}" />
                        </DataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsHostedInRibbonWindow}" Value="True" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=WindowState}" Value="Maximized" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="titleText" Property="Foreground" Value="White" />
                        </MultiDataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- RibbonTab -->

    <Style x:Key="{x:Type r:RibbonTab}" TargetType="{x:Type r:RibbonTab}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="MinWidth" Value="110"/>
        <Setter Property="Height" Value="24"/>
        <Setter Property="Foreground" Value="#0E1D34"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type r:RibbonTab}">
                    <Grid Name="grid">
                        <Border
              Name="Border"
              Margin="0,0,2,0"
              Background="{DynamicResource Brush_RibbonTabBackground}"
              BorderBrush="{DynamicResource Brush_RibbonTabBorder}"
              BorderThickness="0,1,0,0"
              CornerRadius="3,3,0,0">
                            <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{TemplateBinding Label}"/>
                        </Border>
                        <Border x:Name="Shadow" Height="4" VerticalAlignment="Bottom" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource RibbonTabShadowBorderBrush}"
                                Background="{DynamicResource RibbonTabShadowBackgroundBrush}">                            
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Panel.ZIndex" Value="100"/>
                            <Setter Property="Margin" Value="0,-1,0,-1"/>
                            <Setter Property="Height" Value="25"/>
                            <Setter Property="Foreground" Value="{DynamicResource RibbonSelectedTabForegroundBrush}"/>
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource Brush_RibbonSelectedTabBackground}"/>
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Brush_RibbonSelectedTabBorder}"/>
                            <Setter TargetName="Shadow" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- RibbonTextBox -->

    <Style x:Key="{x:Type r:RibbonTextBox}" TargetType="{x:Type r:RibbonTextBox}">
        <Setter Property="Background" Value="{DynamicResource Brush_ControlWindowBackground}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource Brush_ControlWindowBorder}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="AllowDrop" Value="true"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Foreground" Value="#2E3740" />
        <Setter Property="Height" Value="21"/>
        <Setter Property="Margin" Value="0,0,0,4"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource RibbonToolTipInitialShowDelay}"/>
        <Setter Property="ToolTipService.ShowDuration" Value="{StaticResource RibbonToolTipShowDuration}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type r:RibbonTextBox}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="20" />
                            <ColumnDefinition Width="60" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Width="16" Height="16" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.SmallImageSource}"/>
                        <TextBlock Grid.Column="1" Margin="4,4,0,0" Foreground="White" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.LabelTitle}"  />

                        <Border Grid.Column="2" CornerRadius="1" BorderThickness="1" Margin="1,1,0,0">
                            <Border.Background>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Color="#AFFF" Offset="0" />
                                    <GradientStop Color="#FFF" Offset="1" />
                                </LinearGradientBrush>
                            </Border.Background>
                            <Border.BorderBrush>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Color="#3FFF" Offset="0" />
                                    <GradientStop Color="#6FFF" Offset="1" />
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                        </Border>
                        <Border Grid.Column="2" CornerRadius="1" BorderThickness="1" Margin="0,0,1,1" Background="#2FFF">
                            <Border.BorderBrush>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                    <GradientStop Color="#60042D5B" Offset="0" />
                                    <GradientStop Color="#C0042D5B" Offset="1" />
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                        </Border>
                        <ScrollViewer Grid.Column="2" Margin="2" x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- RibbonGroup -->

    <Style x:Key="CollapsedRibbonGroupDropDownButtonToggleButtonStyle" TargetType="{x:Type r:RibbonToggleButton}">
        <Setter Property="RenderOptions.BitmapScalingMode" Value="NearestNeighbor" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type r:RibbonToggleButton}">
                    <Grid>
                        <Border CornerRadius="2" BorderThickness="1" Margin="1" BorderBrush="{DynamicResource RibbonGroupCollapsedBackgroundBorderBrush}" SnapsToDevicePixels="True" />
                        <Border 
              BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupCollapsedOuterBorderBrushKey}}" 
              CornerRadius="2"
              BorderThickness="1"
              SnapsToDevicePixels="True" />
                        <Border Name="PART_HotBackground"
                                Opacity="0"
                                CornerRadius="2"
                                BorderThickness="1"
                                Background="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupCollapsedBackgroundIsMouseOverKey}}"
                                BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupCollapsedBorderBrushIsMouseOverKey}}"
                                SnapsToDevicePixels="True">
                            <Border Name="HotBackgroundInnerBorder" CornerRadius="2" BorderThickness="1" BorderBrush="White" SnapsToDevicePixels="True" />
                        </Border>
                        <Grid Margin="2">
                            <Border Margin="3"
                                        VerticalAlignment="Top"
                                        HorizontalAlignment="Center"
                                        Background="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupCollapsedOuterIconBorderBackgroundKey}}"
                                        BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupCollapsedOuterIconBorderBrushKey}}"
                                        BorderThickness="1"
                                        Width="30"
                                        Height="30"
                                        CornerRadius="3"
                                        SnapsToDevicePixels="True">
                                <Grid>
                                    <Border BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupCollapsedInnerIconBorderBrushKey}}"
                                                BorderThickness="1"
                                                CornerRadius="3"
                                                SnapsToDevicePixels="True" />
                                    <Image Source="{Binding RelativeSource={RelativeSource AncestorType={x:Type r:RibbonGroup}}, Path=Command.SmallImageSource}"
                                               Width="16"
                                               Height="16"
                                               HorizontalAlignment="Center"
                                               VerticalAlignment="Top"
                                               RenderOptions.BitmapScalingMode="{TemplateBinding RenderOptions.BitmapScalingMode}" />
                                    <Rectangle Width="30" Height="8" VerticalAlignment="Bottom" Fill="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupCollapsedIconAccentBrushKey}}" />
                                </Grid>
                            </Border>
                            <r:TwoLineLabel Margin="2,36,2,0"
                                                 Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type r:RibbonGroup}}, Path=Command.LabelTitle}"
                                                 TextAlignment="Center"
                                                 TextWrapping="WrapWithOverflow"
                                                 LineHeight="13px"
                                                 LineStackingStrategy="BlockLineHeight"
                                                 GlyphFill="{DynamicResource {x:Static r:RibbonSkinResources.RibbonDownArrowBrushKey}}"
                                                 HasTwoLines="True"
                                                 Data="{StaticResource DownArrowGeometry}" />
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="PART_HotBackground" Property="Background" Value="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupCollapsedBorderBrushIsCheckedKey}}" />
                            <Setter TargetName="PART_HotBackground" Property="Opacity" Value="1" />
                            <Setter TargetName="HotBackgroundInnerBorder" Property="BorderBrush" Value="Transparent" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CollapsedRibbonGroupDropDownButtonStyle" TargetType="{x:Type r:RibbonDropDownButton}">
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type r:RibbonDropDownButton}">

                    <!-- Override MenuItem default style to simply host a ContentPresenter -->
                    <ControlTemplate.Resources>
                        <Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type MenuItem}">
                                        <ContentPresenter ContentSource="Header"
                                                          RecognizesAccessKey="True"
                                                          VerticalAlignment="Center"
                                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ControlTemplate.Resources>

                    <Grid>
                        <r:RibbonToggleButton x:Name="PART_ToggleButton" Style="{StaticResource CollapsedRibbonGroupDropDownButtonToggleButtonStyle}" />
                        <Popup x:Name="PART_Popup"
                               AllowsTransparency="true"
                               Placement="Bottom"                               
                               PlacementTarget="{Binding ElementName=PART_ToggleButton}"
                               IsOpen="{Binding ElementName=PART_ToggleButton, Path=IsChecked}"
                               Focusable="false"
                               PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}">
                            <theme:SystemDropShadowChrome Name="Shdw" Color="Transparent" SnapsToDevicePixels="true" CornerRadius="2">
                                <ItemsPresenter KeyboardNavigation.TabNavigation="Cycle"
                                                KeyboardNavigation.DirectionalNavigation="Cycle"
                                                SnapsToDevicePixels="True"
                                                Grid.IsSharedSizeScope="true"/>
                            </theme:SystemDropShadowChrome>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger SourceName="PART_Popup" Property="Popup.HasDropShadow" Value="true">
                            <Setter TargetName="Shdw" Property="Margin" Value="0,0,5,5"/>
                            <Setter TargetName="Shdw" Property="Color" Value="#71000000"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="RibbonGroupTemplate" TargetType="{x:Type r:RibbonGroup}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" MinHeight="16" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Border 
        Grid.RowSpan="2"
        BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupInnerBorderBrushKey}}"
        CornerRadius="2"
        BorderThickness="1"
        Margin="1,1,-1,-1"
        SnapsToDevicePixels="True" />
            <Border 
        Grid.RowSpan="2"
        BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupOuterBorderBrushKey}}"
        CornerRadius="2"
        BorderThickness="1"
        Margin="0"
        SnapsToDevicePixels="True" />
            <Rectangle Grid.Row="1" Margin="1,0,1,1" Fill="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupLabelBackgroundBrushKey}}" />
            <Border 
        Name="PART_HotBackground"
        Background="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupBackgroundBrushIsMouseOverKey}}"
        BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupOuterBorderBrushIsMouseOverKey}}"
        Opacity="0"
        Grid.RowSpan="2"
        CornerRadius="2"
        BorderThickness="1"
        SnapsToDevicePixels="True">
                <Border 
          BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupInnerBorderBrushIsMouseOverKey}}"
          CornerRadius="2"
          BorderThickness="1"
          SnapsToDevicePixels="True" />
            </Border>
            <Border Grid.Row="1" Grid.ColumnSpan="2" Margin="-2,0,0,-3" Background="{DynamicResource RibbonGroupInnerBorderBackgroundBrush}" />                 
            <Border 
        Opacity="0.5"
        Background="#B0D4F5"
        BorderBrush="#0E233C"
        BorderThickness="1,0,0,0"
        Grid.Column="1"
        Grid.RowSpan="2"
        Height="104"
        Margin="0"
        Width="2"
        Visibility="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupSeparatorVisibilityKey}}"
        VerticalAlignment="Stretch"
        SnapsToDevicePixels="True" />
            <Rectangle Name="PART_HotTray" Opacity="0" Grid.Row="1" Margin="2,0,2,2" Fill="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupLabelBackgroundBrushIsMouseOverKey}}" />

            <Border Margin="6,10,6,0" x:Name="PART_RibbonControlsHostBorder" />

            <DockPanel Margin="0" Grid.Row="1">
                <r:RibbonDialogLauncher Name="PART_DialogLauncher" DockPanel.Dock="Right" VerticalAlignment="Center" />
                <TextBlock 
          Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.LabelTitle}"
          Margin="2,0,2,2"
          MaxHeight="15"
          HorizontalAlignment="Center"
          VerticalAlignment="Center" />
            </DockPanel>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="HasDialogLauncher" Value="false">
                <Setter TargetName="PART_DialogLauncher" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <EventTrigger RoutedEvent="UIElement.MouseEnter">
                <EventTrigger.Actions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="PART_HotBackground" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                            <DoubleAnimation Storyboard.TargetName="PART_HotTray" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger.Actions>
            </EventTrigger>
            <EventTrigger RoutedEvent="UIElement.MouseLeave">
                <EventTrigger.Actions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="PART_HotBackground" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.4" />
                            <DoubleAnimation Storyboard.TargetName="PART_HotTray" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.4" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger.Actions>
            </EventTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <ControlTemplate x:Key="CollapsedRibbonGroupTemplate" TargetType="{x:Type r:RibbonGroup}">
        <r:RibbonDropDownButton Style="{StaticResource CollapsedRibbonGroupDropDownButtonStyle}" BorderBrush="{DynamicResource CollapsedRibbonGroupDropDownButtonBorderBrush}" >
            <r:RibbonDropDownButton.Items>
                <Grid Height="{TemplateBinding ActualHeight}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" MinHeight="16" />
                    </Grid.RowDefinitions>
                    <Border 
            Grid.RowSpan="2"
            BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.GroupHostInnerBorderBrushKey}}"
            CornerRadius="2"
            BorderThickness="1"
            Margin="1,1,-1,-1"
            SnapsToDevicePixels="True" />
                    <Border Grid.RowSpan="2"
                            Background="{DynamicResource {x:Static r:RibbonSkinResources.GroupHostBackgroundBrushKey}}"
                            BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.GroupHostBorderBrushKey}}"
                            CornerRadius="2"
                            BorderThickness="1"
                            SnapsToDevicePixels="True" />
                    <Rectangle Grid.Row="1" Margin="1,0,1,1" Fill="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupLabelBackgroundBrushKey}}" />
                    <Border Name="PART_HotBackground"
                            Background="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupBackgroundBrushIsMouseOverKey}}"
                            BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupOuterBorderBrushIsMouseOverKey}}"
                            Opacity="0"
                            Grid.RowSpan="2"
                            CornerRadius="2"
                            BorderThickness="1"
                            SnapsToDevicePixels="True">
                        <Border BorderBrush="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupInnerBorderBrushIsMouseOverKey}}"
                                CornerRadius="2"
                                BorderThickness="1"
                                SnapsToDevicePixels="True" />
                    </Border>
                    <Rectangle Name="PART_HotTray" Opacity="0" Grid.Row="1" Margin="2,0,2,2" Fill="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupLabelBackgroundBrushIsMouseOverKey}}" />
                    <Border Margin="2,2,2,0" x:Name="PART_RibbonControlsHostBorder" />
                    <DockPanel Margin="2,0,2,1" Grid.Row="1">
                        <r:RibbonDialogLauncher Name="PART_DialogLauncher" DockPanel.Dock="Right" VerticalAlignment="Center" />
                        <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.LabelTitle}" Margin="2,0,2,0" MaxHeight="15" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#3E6AAA" />
                    </DockPanel>
                </Grid>
            </r:RibbonDropDownButton.Items>
        </r:RibbonDropDownButton>
        <ControlTemplate.Triggers>
            <Trigger Property="HasDialogLauncher" Value="false">
                <Setter TargetName="PART_DialogLauncher" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <EventTrigger RoutedEvent="UIElement.MouseEnter">
                <EventTrigger.Actions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="PART_HotBackground" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                            <DoubleAnimation Storyboard.TargetName="PART_HotTray" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger.Actions>
            </EventTrigger>
            <EventTrigger RoutedEvent="UIElement.MouseLeave">
                <EventTrigger.Actions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="PART_HotBackground" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.4" />
                            <DoubleAnimation Storyboard.TargetName="PART_HotTray" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.4" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger.Actions>
            </EventTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Type r:RibbonGroup}" TargetType="{x:Type r:RibbonGroup}">
        <Style.Triggers>
            <Trigger Property="IsCollapsed" Value="true">
                <Setter Property="Template" Value="{StaticResource CollapsedRibbonGroupTemplate}" />
            </Trigger>
        </Style.Triggers>
        <Setter Property="Margin" Value="1" />
        <Setter Property="Padding" Value="3,0,3,0" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template" Value="{StaticResource RibbonGroupTemplate}" />
    </Style>




    <!-- RibbonButton -->

    <Style x:Key="{x:Type r:RibbonButton}" TargetType="{x:Type r:RibbonButton}">
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static r:RibbonSkinResources.RibbonFontColorBrushKey}}" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="RenderOptions.BitmapScalingMode" Value="NearestNeighbor" />
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource RibbonToolTipInitialShowDelay}" />
        <Setter Property="ToolTipService.ShowDuration" Value="{StaticResource RibbonToolTipShowDuration}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type r:RibbonButton}">
                    <Grid>
                        <Border x:Name="LightBorder" CornerRadius="1" BorderThickness="1" Margin="1,1,0,0" Opacity="1"  Background="Transparent"/>
                        <Border x:Name="Overlay" 
                                BorderBrush="{DynamicResource RibbonButtonOverlayBorderBrush}" 
                                BorderThickness="1.5,1.5,0,0" Margin="2,2,3,3" 
                                CornerRadius="1" Visibility="Collapsed" 
                                Background="{DynamicResource RibbonButtonOverlayBackgroundBrush}">
                            <Border.BitmapEffect>
                                <BlurBitmapEffect Radius="9" />
                            </Border.BitmapEffect>                          
                        </Border>
                        <Border x:Name="DarkBorder" CornerRadius="1" BorderThickness="1" Margin="0,0,1,1" />
                        <StackPanel Name="stackpanel" Margin="6">
                            <Image 
                x:Name="image" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.LargeImageSource}"
                RenderOptions.BitmapScalingMode="{TemplateBinding RenderOptions.BitmapScalingMode}"
                Width="16"
                Height="16"
                VerticalAlignment="Top"
                HorizontalAlignment="Center">
                            </Image>
                            <r:TwoLineLabel 
                x:Name="twoLineLabel"
                Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.LabelTitle}"
                TextAlignment="Center"
                TextWrapping="WrapWithOverflow"
                LineHeight="13px"
                LineStackingStrategy="BlockLineHeight"
                VerticalAlignment="Center"
                Margin="2,3,2,0" />
                        </StackPanel>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="LightBorder" Property="BorderBrush" Value="{DynamicResource Brush_RibbonOverLightBorder}" />
                            <Setter TargetName="LightBorder" Property="Background" Value="{DynamicResource Brush_RibbonOverLightBackground}" />
                            <Setter TargetName="DarkBorder" Property="BorderBrush" Value="{DynamicResource FillOverDarkBorderBrush}" />
                            <Setter TargetName="image" Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect x:Name="ImageGlow" BlurRadius="7" ShadowDepth="1" Color="#FFFFFF" Opacity="1" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="LightBorder" Property="BorderBrush" Value="{DynamicResource Brush_RibbonPressedLightBorder}" />
                            <Setter TargetName="LightBorder" Property="Background" Value="{DynamicResource Brush_RibbonPressedLightBackground}" />
                            <Setter TargetName="Overlay" Property="Visibility" Value="Visible" />
                            <Setter TargetName="DarkBorder" Property="BorderBrush" Value="{DynamicResource Brush_RibbonPressedDarkBorder}" />
                        </Trigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).ImageSize}" Value="Large" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).IsLabelVisible}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="MinWidth" Value="44"/>
                            <Setter Property="Height" Value="66"/>
                            <Setter TargetName="image" Property="Margin" Value="1" />
                            <Setter TargetName="image" Property="Width" Value="22" />
                            <Setter TargetName="image" Property="Height" Value="22" />
                            <Setter TargetName="twoLineLabel" Property="HasTwoLines" Value="True" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).ImageSize}" Value="Small" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).IsLabelVisible}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Height" Value="22"/>
                            <Setter TargetName="image" Property="Margin" Value="1,0,4,0" />
                            <Setter TargetName="image" Property="HorizontalAlignment" Value="Left" />
                            <Setter TargetName="image" Property="Source" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.SmallImageSource}" />
                            <Setter TargetName="twoLineLabel" Property="HorizontalAlignment" Value="Left" />
                            <Setter TargetName="twoLineLabel" Property="Margin" Value="2,0,2,0" />
                            <Setter TargetName="stackpanel" Property="Orientation" Value="Horizontal" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).ImageSize}" Value="Small" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).IsLabelVisible}" Value="False" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Width" Value="22"/>
                            <Setter Property="Height" Value="22"/>
                            <Setter TargetName="image" Property="Margin" Value="1,0,1,0" />
                            <Setter TargetName="image" Property="HorizontalAlignment" Value="Center" />
                            <Setter TargetName="image" Property="Source" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.SmallImageSource}" />
                            <Setter TargetName="twoLineLabel" Property="Visibility" Value="Collapsed" />
                        </MultiDataTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                            <Setter TargetName="image" Property="Opacity" Value="0.4" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- RibbonToggleButton -->

    <Style x:Key="{x:Type r:RibbonToggleButton}" TargetType="{x:Type r:RibbonToggleButton}">
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Foreground" Value="{DynamicResource {x:Static r:RibbonSkinResources.RibbonFontColorBrushKey}}" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="RenderOptions.BitmapScalingMode" Value="NearestNeighbor" />
        <Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource RibbonToolTipInitialShowDelay}" />
        <Setter Property="ToolTipService.ShowDuration" Value="{StaticResource RibbonToolTipShowDuration}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type r:RibbonToggleButton}">
                    <Grid>
                        <Border x:Name="LightBorder" CornerRadius="1" BorderThickness="1" Margin="1,1,0,0" Opacity="1"  Background="Transparent"/>
                        <Border x:Name="Overlay" 
                                BorderBrush="{DynamicResource RibbonToggleButtonOverlayBorderBrush}" 
                                Background="{DynamicResource RibbonToggleButtonOverlayBackgroundBrush}"
                                BorderThickness="1.5,1.5,0,0" 
                                Margin="2,2,3,3" CornerRadius="1" Visibility="Collapsed" >
                            <Border.BitmapEffect>
                                <BlurBitmapEffect Radius="9" />
                            </Border.BitmapEffect>                             
                        </Border>
                        <Border x:Name="DarkBorder" CornerRadius="1" BorderThickness="1" Margin="0,0,1,1" />
                        <StackPanel Name="stackpanel" Margin="6">
                            <Image 
                x:Name="image" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.LargeImageSource}"
                RenderOptions.BitmapScalingMode="{TemplateBinding RenderOptions.BitmapScalingMode}"
                Width="16"
                Height="16"
                VerticalAlignment="Top"
                HorizontalAlignment="Center">
                            </Image>
                            <r:TwoLineLabel 
                x:Name="twoLineLabel"
                Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.LabelTitle}"
                TextAlignment="Center"
                TextWrapping="WrapWithOverflow"
                LineHeight="13px"
                LineStackingStrategy="BlockLineHeight"
                VerticalAlignment="Center"
                Margin="2,3,2,0" />
                        </StackPanel>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="LightBorder" Property="BorderBrush" Value="{DynamicResource Brush_RibbonOverLightBorder}" />
                            <Setter TargetName="LightBorder" Property="Background" Value="{DynamicResource Brush_RibbonOverLightBackground}" />
                            <Setter TargetName="DarkBorder" Property="BorderBrush" Value="{DynamicResource FillOverDarkBorderBrush}" />
                            <Setter TargetName="image" Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect x:Name="ImageGlow" BlurRadius="7" ShadowDepth="1" Color="#FFFFFF" Opacity="1" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="LightBorder" Property="BorderBrush" Value="{DynamicResource Brush_RibbonPressedLightBorder}" />
                            <Setter TargetName="LightBorder" Property="Background" Value="{DynamicResource Brush_RibbonPressedLightBackground}" />
                            <Setter TargetName="Overlay" Property="Visibility" Value="Visible" />
                            <Setter TargetName="DarkBorder" Property="BorderBrush" Value="{DynamicResource Brush_RibbonPressedDarkBorder}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="LightBorder" Property="BorderBrush" Value="{DynamicResource Brush_RibbonPressedLightBorder}" />
                            <Setter TargetName="LightBorder" Property="Background" Value="{DynamicResource Brush_RibbonPressedLightBackground}" />
                            <Setter TargetName="Overlay" Property="Visibility" Value="Visible" />
                            <Setter TargetName="DarkBorder" Property="BorderBrush" Value="{DynamicResource Brush_RibbonPressedDarkBorder}" />
                        </Trigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).ImageSize}" Value="Large" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).IsLabelVisible}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="MinWidth" Value="44"/>
                            <Setter Property="Height" Value="66"/>
                            <Setter TargetName="image" Property="Margin" Value="1" />
                            <Setter TargetName="image" Property="Width" Value="22" />
                            <Setter TargetName="image" Property="Height" Value="22" />
                            <Setter TargetName="twoLineLabel" Property="HasTwoLines" Value="True" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).ImageSize}" Value="Small" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).IsLabelVisible}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Height" Value="22"/>
                            <Setter TargetName="image" Property="Margin" Value="1,0,4,0" />
                            <Setter TargetName="image" Property="HorizontalAlignment" Value="Left" />
                            <Setter TargetName="image" Property="Source" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.SmallImageSource}" />
                            <Setter TargetName="twoLineLabel" Property="HorizontalAlignment" Value="Left" />
                            <Setter TargetName="twoLineLabel" Property="Margin" Value="2,0,2,0" />
                            <Setter TargetName="stackpanel" Property="Orientation" Value="Horizontal" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).ImageSize}" Value="Small" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=(r:RibbonGroup.ControlSizeDefinition).IsLabelVisible}" Value="False" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Width" Value="22"/>
                            <Setter Property="Height" Value="22"/>
                            <Setter TargetName="image" Property="Margin" Value="1,0,1,0" />
                            <Setter TargetName="image" Property="HorizontalAlignment" Value="Center" />
                            <Setter TargetName="image" Property="Source" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Command.SmallImageSource}" />
                            <Setter TargetName="twoLineLabel" Property="Visibility" Value="Collapsed" />
                        </MultiDataTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                            <Setter TargetName="image" Property="Opacity" Value="0.4" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- RibbonApplicationMenu -->

    <Style x:Key="ApplicationMenuToggleButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="Width" Value="36"/>
        <Setter Property="Height" Value="36 "/>
        <Setter Property="Background" Value="Gray"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="ClickMode" Value="Press"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid>
                        <Ellipse Fill="{TemplateBinding Background}">
                            <Ellipse.Effect>
                                <DropShadowEffect BlurRadius="4" Direction="270" ShadowDepth="2"/>
                            </Ellipse.Effect>
                        </Ellipse>
                        <Ellipse x:Name="Ellipse1" Stroke="#50FFFFFF" StrokeThickness="1">
                            <Ellipse.Fill>
                                <RadialGradientBrush Center="0.5,0.87" GradientOrigin="0.5,1.0" RadiusX="2.0" RadiusY="1">
                                    <GradientStop Offset="1" Color="#FFFFFFFF"/>
                                    <GradientStop Offset="0.05" Color="#AAFFFFFF"/>
                                    <GradientStop Offset="0.5" Color="#00FFFFFF"/>
                                    <GradientStop Offset="0.5" Color="#50FFFFFF"/>
                                    <GradientStop Offset="0" Color="#66FFFFFF"/>
                                </RadialGradientBrush>
                            </Ellipse.Fill>
                        </Ellipse>
                        <Ellipse x:Name="Ellipse2" Stroke="#20FFFFFF" StrokeThickness="2">
                            <Ellipse.Fill>
                                <RadialGradientBrush GradientOrigin="0.5,0.6">
                                    <GradientStop Offset="0" Color="#F0FFFFFF"/>
                                    <GradientStop Offset="0.25" Color="#E0FFFFFF"/>
                                    <GradientStop Offset="1" Color="Transparent"/>
                                </RadialGradientBrush>
                            </Ellipse.Fill>
                        </Ellipse>
                        <Ellipse Opacity="0.5" Stroke="{TemplateBinding Background}" StrokeThickness="1"/>
                        <Image HorizontalAlignment="Center" VerticalAlignment="Center" IsHitTestVisible="False" Source="{Binding RelativeSource ={RelativeSource FindAncestor, AncestorType ={x:Type r:RibbonApplicationMenu}},Path=Command.LargeImageSource}" Stretch="None">
                            <Image.Effect>
                                <DropShadowEffect BlurRadius="8" Color="#80FFFFFF" Direction="270" ShadowDepth="1"/>
                            </Image.Effect>
                        </Image>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <LinearGradientBrush x:Key="BlueGradient" StartPoint="0.5,1" EndPoint="0.5,0">
        <GradientStop Offset="0" Color="#FFCBD6E4"/>
        <GradientStop Offset="1" Color="#FFD7E2EF"/>
        <GradientStop Offset="0.23" Color="#FFC9D9ED"/>
        <GradientStop Offset="0.193" Color="#FFCFDDEF"/>
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ApplicationMenuRibbonButtonBackground" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Offset="0" Color="#FFE8F1FC"/>
        <GradientStop Offset="0.49" Color="#FFE9F1FC"/>
        <GradientStop Offset="0.5" Color="#FFD2E1F4"/>
        <GradientStop Offset="1" Color="#FFEBF3FD"/>
    </LinearGradientBrush>
    <Style x:Key="{x:Type r:RibbonApplicationMenu}" TargetType="{x:Type r:RibbonApplicationMenu}">
        <Setter Property="Background" Value="Gray"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type r:RibbonApplicationMenu}">
                    <Grid>
                        <ToggleButton x:Name="PART_MainToggleButton" Margin="3,0,0,0" Background="{TemplateBinding Background}" Style="{StaticResource ApplicationMenuToggleButtonStyle}"/>
                        <Border x:Name="centerBorder" Height="25" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>
                        <Popup x:Name="PART_Popup" AllowsTransparency="True" IsOpen="{Binding ElementName=PART_MainToggleButton,Path=IsChecked}" PlacementTarget="{Binding ElementName=centerBorder}" PopupAnimation="Fade">
                            <theme:SystemDropShadowChrome Margin="0,0,5,5" Color="#71000000" SnapsToDevicePixels="True">
                                <Grid>
                                    <Border BorderBrush="DarkBlue" BorderThickness="1" CornerRadius="3">
                                        <Border Background="#FFC9D9ED" BorderBrush="white" BorderThickness="1" CornerRadius="2">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="15"/>
                                                    <RowDefinition Height="*"/>
                                                    <RowDefinition Height="Auto"/>
                                                </Grid.RowDefinitions>
                                                <Border Background="{DynamicResource BlueGradient}"/>
                                                <Border Grid.Row="1" Margin="3,0,3,0" BorderBrush="White" BorderThickness="1">
                                                    <Border Background="gray" BorderBrush="SkyBlue" BorderThickness="1">
                                                        <Grid>
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="Auto"/>
                                                                <ColumnDefinition Width="2"/>
                                                                <ColumnDefinition Width="300"/>
                                                            </Grid.ColumnDefinitions>
                                                            <Border Background="white">
                                                                <ScrollViewer CanContentScroll="true" Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type FrameworkElement}, ResourceId=MenuScrollViewer}}">
                                                                    <StackPanel Grid.IsSharedSizeScope="true" IsItemsHost="true"/>
                                                                </ScrollViewer>
                                                            </Border>
                                                            <Border x:Name="PART_SubmenuPlaceholder" Grid.Column="2" Background="#FFF0F0F0">
                                                                <!-- MostRecentFiles -->
                                                                <ContentPresenter ContentSource="RecentItemList"/>
                                                                <!--<StackPanel>
                                  <TextBlock FontWeight="Bold" Text="{TemplateBinding MostRecentFilesLabel}" Margin="2" />
                                  <Border Background="white" SnapsToDevicePixels="true" Height="2" BorderThickness="0,1,0,0" BorderBrush="gray"/>
                                  <r:RibbonMostRecentFileItemsControl ItemsSource="{TemplateBinding MostRecentFilesItemsSource}" />
                                </StackPanel-->
                                                            </Border>
                                                            <Border
                                Width="2"
                                Grid.Column="1"
                                HorizontalAlignment="Left"
                                Background="white"
                                BorderBrush="gray"
                                BorderThickness="1,0,0,0"
                                SnapsToDevicePixels="true"/>
                                                        </Grid>
                                                    </Border>
                                                </Border>
                                                <!-- Footer -->
                                                <Grid Grid.Row="2" Background="{DynamicResource BlueGradient}">
                                                    <Grid.Resources>
                                                        <!-- RibbonButton style in a RibbonApplicationMenu -->
                                                        <Style TargetType="{x:Type r:RibbonButton}">
                                                            <Setter Property="r:RibbonGroup.ControlSizeDefinition">
                                                                <Setter.Value>
                                                                    <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True"/>
                                                                </Setter.Value>
                                                            </Setter>
                                                            <Setter Property="Background" Value="{DynamicResource ApplicationMenuRibbonButtonBackground}"/>
                                                            <Setter Property="BorderBrush" Value="#FF7793B9"/>
                                                        </Style>
                                                    </Grid.Resources>
                                                    <ContentPresenter Margin="2" ContentSource="Footer"/>
                                                </Grid>
                                            </Grid>
                                        </Border>
                                    </Border>
                                    <Canvas>
                                        <ToggleButton Name="PART_PopupToggleButton" Background="{Binding ElementName=PART_MainToggleButton, Path=Background}" IsChecked="{Binding ElementName=PART_MainToggleButton,Path=IsChecked}" Style="{StaticResource ApplicationMenuToggleButtonStyle}"/>
                                    </Canvas>
                                </Grid>
                            </theme:SystemDropShadowChrome>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" SourceName="PART_MainToggleButton" Value="true">
                            <Trigger.EnterActions>
                                <StopStoryboard BeginStoryboardName="UncheckedStoryboard"/>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.1" Storyboard.TargetProperty="Background.Color" To="#478AD0"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <StopStoryboard BeginStoryboardName="UncheckedStoryboard"/>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.3" Storyboard.TargetProperty="Background.Color"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsChecked" SourceName="PART_MainToggleButton" Value="true">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.1" Storyboard.TargetProperty="Background.Color" To="Orange"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Name="UncheckedStoryboard">
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.3" Storyboard.TargetProperty="Background.Color"/>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>